package com.wc.blue_bridge_history.Java14Q.D_子矩阵;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/3/24 16:23
 * @description https://www.lanqiao.cn/paper/3874/problem/3521/
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 1010;
    static int[][] a = new int[N][N];
    static int n, m, A, B;
    static int P = 998244353;

    public static void main(String[] args) {
        n = sc.nextInt();
        m = sc.nextInt();
        A = sc.nextInt();
        B = sc.nextInt();
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                a[i][j] = sc.nextInt();
            }
        }
        long res = 0;
        ArrayList<LinkedList<Integer>> maxQs = new ArrayList<>();
        ArrayList<LinkedList<Integer>> minQs = new ArrayList<>();
        for (int i = 0; i <= m; i++) {
            maxQs.add(new LinkedList<>());
            minQs.add(new LinkedList<>());
        }

        // 先将每一列加上1 ~ A - 1列
        for (int i = 1; i <= m; i++) {
            for (int j = 1; j < A; j++) {
                pushMax(a[j][i], maxQs.get(i));
                pushMin(a[j][i], minQs.get(i));
            }
        }
        for (int i = A; i <= n; i++) {
            // 将第i行的加入
            for (int j = 1; j <= m; j++) {
                pushMax(a[i][j], maxQs.get(j));
                pushMin(a[i][j], minQs.get(j));
            }

            // 新建一个最大队列和最小队列
            LinkedList<Integer> maxQ = new LinkedList<>();
            LinkedList<Integer> minQ = new LinkedList<>();
            // 将前1 ~ B - 1的加入到这两个队列当中
            for (int j = 1; j < B; j++) {
                pushMax(maxQs.get(j).get(0), maxQ);
                pushMin(minQs.get(j).get(0), minQ);
            }

            for (int j = B; j <= m; j++) {
                // 先将这一列加入到最大队列和最小队列当中
                pushMax(maxQs.get(j).get(0), maxQ);
                pushMin(minQs.get(j).get(0), minQ);
                res = (res + (long) maxQ.get(0) * minQ.get(0)) % P;
                // 将最前面一列剔除
                popMax(maxQs.get(j - B + 1).get(0), maxQ);
                popMin(minQs.get(j - B + 1).get(0), minQ);
            }
            // 将第 i - A + 1剔除
            for (int j = 1; j <= m; j++) {
                popMax(a[i - A + 1][j], maxQs.get(j));
                popMin(a[i - A + 1][j], minQs.get(j));
            }
        }
        out.println(res);
        out.flush();
    }

    static void pushMax(int x, LinkedList<Integer> maxQ) {
        while (maxQ.size() > 0 && x > maxQ.get(maxQ.size() - 1)) maxQ.removeLast();
        maxQ.add(x);
    }

    static void popMax(int x, LinkedList<Integer> maxQ) {
        if (x == maxQ.get(0)) maxQ.removeFirst();
    }

    static void pushMin(int x, LinkedList<Integer> minQ) {
        while (minQ.size() > 0 && x < minQ.get(minQ.size() - 1)) minQ.removeLast();
        minQ.add(x);
    }

    static void popMin(int x, LinkedList<Integer> minQ) {
        if (x == minQ.get(0)) minQ.removeFirst();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
